package org.fhm.zdte.common.service.transmission;


import org.fhm.zdte.common.pojo.Address;
import org.fhm.zdte.common.protocol.AbstractMessageStandard;
import org.fhm.zdte.common.standard.IDataDeal;
import org.fhm.zdte.common.standard.ISubCmd;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;

/**
 * The abstract layer for the data processor.
 *
 * @author 谭波
 * @since 2024/1/31
 */
public abstract class AbstractDataDeal implements IDataDeal<ISubCmd, Address, AbstractMessageStandard> {

    /**
     * The container for store the data processing consumer.
     */
    protected final Map<ISubCmd, BiConsumer<Address, AbstractMessageStandard>> dealMapping = new ConcurrentHashMap<>();

    @Override
    public IDataDeal<ISubCmd, Address, AbstractMessageStandard> putConsumer(ISubCmd r, BiConsumer<Address, AbstractMessageStandard> biConsumer) {
        dealMapping.put(r, biConsumer);
        return this;
    }

}
